package main

import (
	"Demo03/part03/FuncHello"
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	r := gin.Default()

	r.LoadHTMLGlob("part03/templates/**/*")

	r.StaticFS("/s", http.Dir("part03/static"))

	//通过访问路径进行获取
	//访问地址 http://localhost:8080/demo01/1001
	//路由要求传入:id占位符参数，必须传入否则报错
	r.GET("/demo01/:id", FuncHello.Hello1)

	//路由要求传入*id占位符参数，如果没有不会报错，但是没有值
	r.GET("/demo02/*id", FuncHello.Hello2)

	//访问地址是键值对http://localhost:8080/demo03?id=123&name=%E4%B8%BD%E4%B8%BD
	r.GET("/demo03", FuncHello.Hello3)

	r.GET("/demo04", FuncHello.Hello4)

	//访问地址 http://localhost:8080/demo05?id=1,2,3,4,5
	r.GET("/demo05", FuncHello.Hello5)

	//http://localhost:8080/demo06?user[1001]=%E5%BC%A0%E4%B8%89&user[1002]=%E4%B8%BD%E4%B8%BD
	r.GET("/demo06", FuncHello.Hello6)

	r.Run()

}
